package GUI;

import IO.RoutersIO;
import Roteador.Router;

public class Main {

	/**
	 * Inicia a interface gráfica
	 * @param args mínimo 1, nesta ordem: ID, timeout, tempo de reenvio
	 */
	public static void main(String[] args) {
		Router r;
		String id;
		String timeout = null;
		String resend = null;
		switch (args.length) {
		case 0: {System.out.println("Insira pelo menos 1 parametro"); System.exit(1);}
		case 1: {id = args[0]; break;}
		case 2: {id = args[0]; timeout = args[1]; break;}
		default: {id = args[0]; timeout = args[1]; resend = args[2];}

		}


		try {
			r = new Router(id,RoutersIO.getIpFromId(id),RoutersIO.getPortFromId(id));
			if( timeout != null) r.setTimeout(Long.parseLong(timeout)*1000);
			if (resend != null) r.setTimeForSending(Long.parseLong(resend)*1000);
			r.start();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
	}

}
